<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title>电费充值</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" type="text/css" href="../bootstrap/dist/css/bootstrap.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/bootstrap-datetimepicker.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/iconfont.css" />

	</head>
	<style type="text/css">
		.remove {
			cursor: pointer;
		}
		
		.remove:hover {
			color: red;
		}
		
		.pagination span {
			font: 14px/34px "";
			padding: 0 5px;
		}
		
		.form-control {
			display: inline-block;
			width: 160px;
		}
		
		.header {
			/*border-bottom: 1px solid #fefefe;*/
		}
		
		.header span {
			padding: 0 5px;
		}
		
		.icon {
			width: 22px;
			height: 22px;
			vertical-align: -6px;
			fill: currentColor;
			overflow: hidden;
		}
		
		.span {
			font: 14px/22px "";
		}
		
		.pay_menthos {
			width: 500px;
			margin-top: 50px;
			/*margin-left:50px*/
		}
		
		ul {
			width: 100%;
		}
		
		ul .list-group-item {
			display: flex;
			justify-content: space-between;
			flex-wrap: nowrap;
		}
		
		.sure_pay {
			display: block;
			margin: 50px auto;
		}
		
		.modal-body {
			max-height: 500px;
			overflow-y: auto;
		}
		
		.radio {
			margin: 20px 0
		}
		
		input[type=radio] {
			/*width:20px;
			height:20px;	
			border-radius:0px;	*/
		}
		.pay_menthos{
			display: none;
		}
		.table_cla {
			height: 560px;
		}
	</style>

	<body>
		<div id="app" style="width: 100%; margin: 0 auto;padding:0 20px;">
			<div class="header" style="margin-top: 20px;">
				<!--<span>楼宇：</span>-->
				<select name="" class="form-control" v-model="build_model" @change="buildchange">
					<option v-for="index in build" :value="index.id" v-text="index.buildname"></option>
				</select>
				<!--<span>单元：</span>-->
				<select name="" class="form-control" v-model="unit_model" @change="unitchange">
					<option v-for="index in unit" :value="index.id" v-text="index.unitname"></option>
				</select>
				<!--<span>楼层：</span>-->
				<select name="" class="form-control" v-model="floor_model" @change="floorchange">
					<option v-for="index in floor" :value="index.id" v-text="index.floorname"></option>
				</select>
				<!--<span>房号：</span>-->
				<select name="" class="form-control" v-model="room_model">
					<option v-for="index in room" :value="index.rommid" v-text="index.rommcode"></option>
				</select>
				<input type="text" class="form-control" name="search1" id="search1" value="" v-model="searchmain" placeholder="请输入电表号或房号" />
				<button type="button" class="btn btn-info" data-dismiss="modal" @click="search">搜索</button>
			</div>

			<!-- 模态框（Modal）确认信息 -->
			<div class="modal fade" id="myModal" data-backdrop="static" data-keyboard="false" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title" id="myModalLabel">选择房屋</h4>
						</div>
						<div class="modal-body">
							<div class="radio" v-for="item in room_main">
								<label>										
									<input type="radio" v-model="equipsid" name="optionsRadios" :id="item.equipsid" :value="item" > 
									{{item.custname+"--"+item.buildname+"/"+item.units+"/"+item.floor+"/"+item.rommcode+"/"+item.instadr+"/"+item.watchno}}
								</label>
							</div>
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
							<button type="button" class="btn btn-success sure_room" @click="sure_room">{{button_read_biao}}</button>
						</div>
					</div>
				</div>
			</div>
			<!--支付方式-->
			<div class="pay_menthos">
				<ul class="list-group">
					<li class="list-group-item">
						<span>业主:</span>
						<span v-text="equipsid.custname"></span>
					</li>
					<li class="list-group-item">
						<span>楼宇:</span>
						<span v-text="equipsid.buildname"></span>
					</li>
					<li class="list-group-item">
						<span>单元：</span>
						<span v-text="equipsid.units"></span>
					</li>
					<li class="list-group-item">
						<span>楼层:</span>
						<span v-text="equipsid.floor"></span>
					</li>
					<li class="list-group-item">
						<span>房号：</span>
						<span v-text="equipsid.rommcode"></span>
					</li>
					<li class="list-group-item">
						<span>安装位置：</span>
						<span v-text="equipsid.instadr"></span>
					</li>
					<li class="list-group-item">
						<span>表号：</span>
						<span v-text="equipsid.watchno"></span>
					</li>
					<li class="list-group-item">
						<span>余额：</span>
						<span v-text="table_data.balance+'元'"></span>
					</li>
					<li class="list-group-item">
						<span>充值次数：</span>
						<span v-text="table_data.times"></span>
					</li>
					<li class="list-group-item">
						<span>倍率：</span>
						<span v-text="table_data.rate"></span>
					</li>
					<li class="list-group-item">
						<span>欠费：</span>
						<span v-text="table_data.owe"></span>
					</li>
					<li class="list-group-item">
						<span>充值金额：</span>
						<!--<input type="number" name="moner_pay" min="1" v-model='pay_monet' id="moner_pay" placeholder="请输入充值金额" value="" />-->
						<input placeholder="请输入充值金额"  name="moner_pay" min="1" v-model='pay_monet' id="moner_pay" oninput="value=value.replace(/[^\d]/g,'')">
						
					</li>

				</ul>
				<div class="" style="text-align: center">
					<lable>
						<input type="radio" v-model="pay_method_id" name="pay_method" value="1">
						<svg class="icon" aria-hidden="true">
							<use xlink:href="#icon-wxpay"></use>
						</svg>
						<span class="span">微信支付</span>
					</lable>
					<lable>
						<input type="radio" v-model="pay_method_id" name="pay_method" value="2">
						<svg class="icon" aria-hidden="true">
							<use xlink:href="#icon-zhifubaozhifu"></use>
						</svg>
						<span class="span">支付宝支付</span>
					</lable>
					<lable>
						<input type="radio" v-model="pay_method_id" name="pay_method" value="5">
						<svg class="icon" aria-hidden="true">
							<use xlink:href="#icon-cash_payment"></use>
						</svg>
						<span class="span">现金支付</span>
					</lable>
					<lable>
						<input type="radio" v-model="pay_method_id" name="pay_method" value="6">
						<svg class="icon" aria-hidden="true">
							<use xlink:href="#icon-card"></use>
						</svg>
						<span class="span">POS支付</span>
					</lable>
				</div>
				<input v-model="authcode" id="inputVal" v-on:input="watch_ma" style="opacity: 0;" placeholder="付款码" />
				<div class="">
					<button type="button" @click="pay" class="btn btn-info sure_pay">{{sure_pay}}</button>
				</div>

			</div>

			<!-- 模态框（Modal）提示信息 -->
			<div class="modal fade" id="myModal_tips" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title" id="myModalLabel">提示信息</h4>
						</div>
						<div class="modal-body" id="tips" v-text="tips_modal">
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
						</div>
					</div>
				</div>
			</div>

			<!-- 模态框（Modal）提示信息 -->
			<div class="modal fade" data-backdrop="static" data-keyboard="false" id="myModal_tips1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title" id="myModalLabel">确认收款</h4>
						</div>
						<div class="modal-body" id="tips" v-text="tips_modal">
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
							<button type="button" class="btn btn-success sure_cash_pos" data-dismiss="modal">确认</button>
						</div>
					</div>
				</div>
			</div>
			<!-- 模态框（Modal）等待扫码 -->
			<div class="modal fade" data-backdrop="static" data-keyboard="false" id="myModal_tips2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="false">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-body" id="tips">
							等待扫码，请勿其他操作
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>

</html>
<script src="../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
<script src="../bootstrap/dist/js/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/bootstrap-datetimepicker.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/bootstrap-datetimepicker.zh-CN.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/public.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/iconfont.js" type="text/javascript" charset="utf-8"></script>
<script>
	new Vue({
		el: '#app',
		data: {
			urlr: "",
			url_bao: "",
			pay_monet: "",
			equipsid: "",
			tips_modal: "",
			searchmain: "",
			pay_method_id: "",
			userid: "",
			authcode: "",
			token: "",
			goodsid: "",
			sure_pay: "确定",
			areaid: "",
			pay_me: false,
			billid:"",
			button_read_biao: "确认",
			id_type: "",
			data_xs: "",
			build: [{
				buildname: '请选择楼宇',
				id: ""
			}],
			build_model: "",
			unit: [{
				unitname: '请选择单元',
				id: ""
			}],
			unit_model: '',
			floor: [{
				floorname: '请选择楼层',
				id: ""
			}],
			floor_model: '',
			room: [{
				rommcode: '请选择房号',
				rommid: ""
			}],

			room_model: '',
			pay_method: [{
					name: "微信支付",
					id: "1",
					className: "icon-wxpay",
				},
				{
					name: "支付宝支付",
					id: "2",
					className: "icon-zhifubaozhifu",
				}, {
					name: "现金支付",
					id: "3",
					className: "icon-cash_payment",
				}, {
					name: "POS支付",
					id: "4",
					className: "icon-card",
				},
			],
			room_main: [

			],
			table_data: ""

		},
		created: function() {
			var aa = getUrl();
			var that = this;
			that.urlr = aa;
			that.build_model = that.build[0].id;
			that.unit_model = that.unit[0].id;
			that.floor_model = that.floor[0].id;
			that.room_model = that.room[0].rommid;
			that.url_bao = getUrl_xiaobao();
				
		},
		mounted: function() {
			var userid = this.getUrlParam('userid');
			this.userid = userid;
			var createusername = this.getUrlParam('realname');
			var merchantid = this.getUrlParam('merchantid');
			var areaid = this.getUrlParam('areaid');
			this.areaid = areaid;
			var token = this.getUrlParam('token');
			this.token = token;
			var goodsid = this.getUrlParam('goodsid');

			if(userid == null || userid == '') {
				this.tips_modal = "用户id不能为空";
				$('#myModal_tips').modal('show');
				return;
			} else {
				this.userid = userid				
			}
			if(createusername == null || createusername == '') {
				this.tips_modal = "用户姓名不能为空";
				$('#myModal_tips').modal('show');
				return;
			} else {
				this.realname = createusername
			}
			if(areaid == null || areaid == '') {
				this.tips_modal = "小区id不能为空";
				$('#myModal_tips').modal('show');
				return;
			} else {
				this.areaid = areaid
			}
			if(merchantid == null || merchantid == '') {
				this.tips_modal = "物业id不能为空";
				$('#myModal_tips').modal('show');
				return;
			} else {
				this.merchantid = merchantid;
			}
			if(token == null || token == '') {
				this.tips_modal = "非法登录";
				$('#myModal_tips').modal('show');
				return;
			} else {
				this.token = token;
			}
			if(goodsid == null || goodsid == '') {
				this.tips_modal = "非法登录";
				$('#myModal_tips').modal('show');
				return;
			} else {
				this.goodsid = goodsid;
			}
			this.lou_info(areaid);
			var isprint = this.getUrlParam('isprint');
			this.data_xs = JSON.parse(sessionStorage.getItem("data_xs"));
			if(isprint) {
				this.search(this.data_xs);
			} else {
				this.lou_info(areaid);
			}
		},
		methods: {
			//获取url
			getUrlParam: function(name) {
				var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
				var r = window.location.search.substr(1).match(reg); //匹配目标参数
				if(r != null) return decodeURI(r[2]);
				return null; //返回参数值
			},
			//获取楼宇
			lou_info: function(areaid) {
				var that = this;
				var data = JSON.stringify({
					parentid: that.areaid
				})
				$.ajax({
					contentType: "application/json; charset=utf-8",
					type: "POST",
					url: that.urlr + "/public/selectBuildList",
					data: data,
					async: true,
					dataType: "json",
					success: function(msg) {
						//						console.log(msg);
						if(msg.code == 200) {
							var aa = JSON.parse(msg.returnString);
							var te = {
								buildname: '请选择楼宇',
								id: ""
							}
							aa.unshift(te);
							that.build = aa;
							that.build_model = that.build[0].id;
						} else {
							//							alert(msg.disp)
							that.tips_modal = msg.disp;
							$('#myModal_tips').modal('show');
						}
					},
					error: function() {
						//						alert("获取信息失败");
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
					}
				});
			},

			//楼改变请求单元
			buildchange: function() {
				this.unil_info(this.build_model);
			},
			//获取单元
			unil_info: function(areaid) {
				if(areaid != "") {
					var that = this;
					var data = JSON.stringify({
						parentid: areaid
					})
					$.ajax({
						contentType: "application/json; charset=utf-8",
						type: "POST",
						url: that.urlr + "/public/selectUnitsList",
						data: data,
						async: true,
						dataType: "json",
						success: function(msg) {
							//							console.log(msg);
							if(msg.code == 200) {
								var aa = JSON.parse(msg.returnString);
								var te = {
									unitname: '请选择单元',
									id: ""
								}
								aa.unshift(te);
								that.unit = aa;
								that.unit_model = that.unit[0].id;
							} else {
								//							alert(msg.disp)
								that.tips_modal = msg.disp;
								$('#myModal_tips').modal('show');
							}
						},
						error: function() {
							//						alert("获取信息失败");
							that.tips_modal = "获取信息失败";
							$('#myModal_tips').modal('show');
						}
					});
				}

			},
			/*单元改变*/
			unitchange: function() {
				this.floor_info(this.unit_model);
			},
			//获取楼层
			floor_info: function(areaid) {
				if(areaid != "") {
					var that = this;
					var data = JSON.stringify({
						parentid: areaid
					})
					$.ajax({
						contentType: "application/json; charset=utf-8",
						type: "POST",
						url: that.urlr + "/public/selectFloors",
						data: data,
						async: true,
						dataType: "json",
						success: function(msg) {
							//							console.log(msg);
							if(msg.code == 200) {
								var aa = JSON.parse(msg.returnString);
								var te = {
									floorname: '请选择楼层',
									id: ""
								}
								var flloor = [];
								for(var i = 1; i <= aa; i++) {
									var main = {
										floorname: i + "层",
										id: i
									}
									flloor.push(main)
								}
								flloor.unshift(te);
								that.floor = flloor;
								that.floor_model = that.floor[0].id;
							} else {
								//							alert(msg.disp)
								that.tips_modal = msg.disp;
								$('#myModal_tips').modal('show');
							}
						},
						error: function() {
							//						alert("获取信息失败");
							that.tips_modal = "获取信息失败";
							$('#myModal_tips').modal('show');
						}
					});
				}

			},
			//楼层改变
			floorchange: function() {
				var that = this;
				if(this.unit_model == '' || this.floor_model == '') {
					var aa = [];
					var te = {
						rommcode: '请选择房号',
						rommid: ""
					}
					aa.unshift(te);
					that.room = aa;
					that.room_model = that.room[0].rommid;
				} else {
					this.room_info(this.unit_model, this.floor_model);
				}
			},
			//出现房屋
			room_info: function(areaid, floor_c) {
				if(areaid != "" || floor_c != "") {
					var that = this;
					var data = JSON.stringify({
						parentid: areaid,
						floor: floor_c
					})
					$.ajax({
						contentType: "application/json; charset=utf-8",

						type: "POST",
						url: that.urlr + "/public/selectRoomCodeList",
						data: data,
						async: true,
						dataType: "json",
						success: function(msg) {
							//							console.log(msg);
							if(msg.code == 200) {
								var aa = JSON.parse(msg.returnString);
								var te = {
									rommcode: '请选择房号',
									rommid: ""
								}
								aa.unshift(te);
								that.room = aa;
								that.room_model = that.room[0].rommid;
							} else {
								that.tips_modal = msg.disp;
								$('#myModal_tips').modal('show');
							}
						},
						error: function() {
							that.tips_modal = "获取信息失败";
							$('#myModal_tips').modal('show');
						}
					});
				}
			},
			//查询
			search_1: function() {
				var that = this;
				var data = {
					areaid: that.areaid,
					unitid: that.unit_model,
					rommid: that.room_model,
					floor: that.floor_model,
					selectinfo: that.searchmain,
					buildid: that.build_model
				}
				that.data_xs = data;
				that.search(data);
			},
			//查询			
			search: function(data) {
				var that = this;
				var data = {
					areaid: that.areaid,
					unitid: that.unit_model,
					rommid: that.room_model,
					floor: that.floor_model,
					selectinfo: that.searchmain,
					buildid: that.build_model
				}
				$.ajax({
					url: that.urlr + "/verify/elepro/selectEleMeterList",
					type: "POST",
					data: JSON.stringify(data),
					dataType: "json",
					contentType: "application/json",
					headers: {
						"userid": that.userid,
						"token": that.token
					},
					success: function(msg) {
						//						console.log(msg);
						if(msg.code == 200) {
							$('#myModal').modal('show');
							that.room_main = JSON.parse(msg.returnString);
						} else {
							that.tips_modal = msg.disp;
							$('#myModal_tips').modal('show');
						}
					},
					error: function() {
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
					}
				});
			},
			//确定选择房屋
			sure_room: function() {
				//				console.log(this.equipsid);
				if(this.equipsid == '') {
					this.tips_modal = "请先选择房屋";
					$('#myModal_tips').modal('show');
				} else {
					this.reading_meter()
				}

			},
			//读表
			reading_meter: function() {
				var that = this;
				var data = {
					equipsid: that.equipsid.equipsid,
				}
				$('.sure_room').prop('disabled', true);
				that.button_read_biao = '读表中请稍后...'
				$.ajax({
					url: that.urlr + "/verify/elepro/selectEleMeterInfo",
					type: "POST",
					data: JSON.stringify(data),
					dataType: "json",
					contentType: "application/json",
					headers: {
						"userid": that.userid,
						"token": that.token
					},
					success: function(msg) {
						//						console.log(msg);
						if(msg.code == 200) {
							that.table_data = JSON.parse(msg.returnString);
//							that.pay_me = true;
							$(".pay_menthos").show();							
							$('#myModal').modal('hide');
							$('.sure_room').prop('disabled', false);
							that.button_read_biao = '确认'
						} else {
							that.tips_modal = msg.disp;
							$('#myModal_tips').modal('show');
							$('.sure_room').prop('disabled', false);
							that.button_read_biao = '确认'
						}
					},
					error: function() {
						$('.sure_room').prop('disabled', false);
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
						that.button_read_biao = '确认'
					}
				});
			},
			//支付
			pay: function() {			
				var that = this;
				if(that.pay_method_id == '') {
					that.tips_modal = "请先选择支付方式";
					$('#myModal_tips').modal('show');
					return
				} else if(that.pay_monet == "") {
					that.tips_modal = "请输入充值金额";
					$('#myModal_tips').modal('show');
					return
				} else if(that.pay_monet % that.table_data.rate != 0) {
					that.tips_modal = "充值金额必须是倍率的整数倍";
					$('#myModal_tips').modal('show');
					return
				}
				var data = {
					equipsid: that.equipsid.equipsid,
					goodsid: that.goodsid,
					paykind: that.pay_method_id,
					paymentamt: that.pay_monet,
					createuserid: that.userid,
					createusername: that.realname,
					orderinfotype: 1
				}
				if(that.pay_method_id == 1 || that.pay_method_id == 2) {
					document.getElementById("inputVal").focus();
					that.id_type_wx_zfb(data)
				}
				if(that.pay_method_id == 5 || that.pay_method_id == 6) {
					that.tips_modal = "请确认现金已收取或者POS付款已支付";
					$('#myModal_tips1').modal('show');
					$(".sure_cash_pos").click(function() {
						//						console.log(that)
						that.id_type1(data)
					})
				}
			},
			//请求后台，拿到订单id和订单状态  支付方式为5 和6
			id_type1: function(data) {
				var that = this;
				$.ajax({
					url: that.urlr + "/verify/elepro/addEleMeterOrder",
					type: "POST",
					data: JSON.stringify(data),
					dataType: "json",
					contentType: "application/json",
					headers: {
						"userid": that.userid,
						"token": that.token
					},
					success: function(msg) {
						if(msg.code == 200) {
							that.tips_modal = "充值成功";
							$('#myModal_tips').modal('show');
							var aa = JSON.parse(msg.returnString);
							that.billid = aa.billid;
							$('#myModal_tips').on('hide.bs.modal', function() {
//								window.location.href("index.html?repaint=paid_the_bill&order=" + that.billid);
								window.parent.postMessage({billid:that.billid}, "*");
								that.data_xs.xiaohua_id="dce";								
								var data_sess = JSON.stringify(that.data_xs);								
								sessionStorage.setItem("data_xs", data_sess);	
							})
						} else {
							that.tips_modal = msg.disp;
							$('#myModal_tips').modal('show');
						}
					},
					error: function() {
						$('.sure_room').prop('disabled', false);
						that.tips_modal = "获取信息失败";
					}
				});
			},
			//请求后台，拿到订单id和订单状态  支付方式为1 和2
			id_type_wx_zfb: function(data) {
				var that = this;
				$.ajax({
					url: that.urlr + "/verify/elepro/addEleMeterOrder",
					type: "POST",
					data: JSON.stringify(data),
					dataType: "json",
					contentType: "application/json",
					headers: {
						"userid": that.userid,
						"token": that.token
					},
					success: function(msg) {
						//						console.log(msg);
						if(msg.code == 200) {
//							console.log(msg);
							var pay_data = JSON.parse(msg.returnString)
							that.wx_zfb_pay(pay_data);
							that.authcode = "";
							document.getElementById("inputVal").focus()
						} else {
							that.tips_modal = msg.disp;
							$('#myModal_tips').modal('show');
						}
					},
					error: function() {
						$('.sure_room').prop('disabled', false);
						that.tips_modal = "获取信息失败";
					}
				});
			},
			//微信和支付宝支付、、开始扫码
			wx_zfb_pay: function(data) {
				var that = this;
				that.id_type = data;
				that.sure_pay = "等待扫码";
				$('.sure_pay').prop('disabled', true);
				//给输入验证码的框子焦点
				document.getElementById("inputVal").focus();
			},
			//监听扫码枪是否扫码成功
			watch_ma: function() {
				var that = this;
				var aa = that.authcode;
				if(aa.length >= 18) {
					if(that.pay_method_id == 1) {
						that.pay_xiaobao()
					} else if(that.pay_method_id == 2) {
						that.pay_xiaobao_zxb()
					}

				}
			},
			//微信支付、、调小包
			pay_xiaobao: function() {
				var that = this;
				that.billid=that.id_type.billid;
				if(that.authcode == "") {
					that.tips_modal = "没有付款码";
					$('#myModal_tips').modal('show');
				}
				var data_1 = {
					id: that.id_type.billid,
					billtype: that.id_type.billtype,
					body: "电表充值",
					authcode: that.authcode,
					areaid: that.areaid,
					totalfee: that.pay_monet,
				}
				$.ajax({
					url: that.url_bao + '/action/wxpay',
					type: "POST",
					data: JSON.stringify(data_1),
					dataType: "json",
					contentType: "application/json",
					success: function(msg) {
						//						console.log(msg);
						if(msg.code == 200) {
							that.tips_modal = msg.msg;
							$('#myModal_tips').modal('show');
							$('#myModal_tips2').modal('hide');
							$('.sure_pay').prop('disabled', false);
							$('#myModal_tips').on('hide.bs.modal', function() {
//								window.location.href("index.html?repaint=paid_the_bill&order=" + that.billid);
								window.parent.postMessage({billid:that.billid}, "*");
								that.data_xs.xiaohua_id="dce";								
								var data_sess = JSON.stringify(that.data_xs);								
								sessionStorage.setItem("data_xs", data_sess);	
							})
						} else if(msg.code == 201) {
							that.sure_pay = msg.msg;
							that.wx_zfb_search()
						} else if(msg.code == 203) {
							that.sure_pay = msg.msg;
							that.wx_zfb_search()
						} else if(msg.code == 202) {
							that.tips_modal = msg.msg;
							$('#myModal_tips').modal('show');
							$('.sure_pay').prop('disabled', false);
							that.sure_pay = "确定"
						}
					},
					error: function() {
						$('.sure_room').prop('disabled', false);
						that.tips_modal = "获取信息失败";
					}
				});
			},
			//支付宝支付、、调小包
			pay_xiaobao_zxb: function() {
			that.billid=that.id_type.billid;
				var that = this;
				if(that.authcode == "") {
					that.tips_modal = "没有付款码";
					$('#myModal_tips').modal('show');
				}
				var data_1 = {
					id: that.id_type.billid,
					billtype: that.id_type.billtype,
					body: "电表充值",
					authcode: that.authcode,
					areaid: that.areaid,
					totalfee: that.pay_monet,
				}
				
				$.ajax({
					url: that.url_bao + '/action/tradepay',
					type: "POST",
					data: JSON.stringify(data_1),
					dataType: "json",
					contentType: "application/json",
					success: function(msg) {
						//						console.log(msg);
						if(msg.code == 200) {
							$('#myModal_tips').on('hide.bs.modal', function() {//								
								window.parent.postMessage({billid:that.billid}, "*");
								that.data_xs.xiaohua_id="dce";								
								var data_sess = JSON.stringify(that.data_xs);								
								sessionStorage.setItem("data_xs", data_sess);	
//								window.location.href("index.html?repaint=paid_the_bill&order=" + that.billid);
							})
							that.tips_modal = msg.msg;
							$('#myModal_tips').modal('show');
							$('#myModal_tips2').modal('hide');
							$('.sure_pay').prop('disabled', false);

						} else if(msg.code == 201) {
							that.sure_pay = msg.msg;
							that.wx_zfb_search1()
						} else if(msg.code == 203) {
							that.sure_pay = msg.msg;
							that.wx_zfb_search1()
						} else if(msg.code == 202) {
							that.tips_modal = msg.msg;
							$('#myModal_tips').modal('show');
							$('.sure_pay').prop('disabled', false);
							that.sure_pay = "确定"
						}
					},
					error: function() {
						$('.sure_room').prop('disabled', false);
						that.tips_modal = "获取信息失败";
					}
				});
			},
			//微信小包查询接口
			wx_zfb_search: function() {
				$('.sure_pay').prop('disabled', true);
				var that = this;
				var data_1 = {
					id: that.id_type.billid,
					billtype: that.id_type.billtype,
					areaid: that.areaid,
				}
				$.ajax({
					url: that.url_bao + '/action/wxquery   ',
					type: "POST",
					async: true,
					data: JSON.stringify(data_1),
					dataType: "json",
					contentType: "application/json",
					success: function(msg) {
						$('.sure_pay').prop('disabled', false);
						//						console.log(msg);
						if(msg.code == 200) {
							that.tips_modal = msg.msg;
							$('#myModal_tips').modal('show');
							$('#myModal_tips2').modal('hide');
							$('#myModal_tips').on('hide.bs.modal', function() {
//								window.location.href("index.html?repaint=paid_the_bill&order=" + that.billid);
								window.parent.postMessage({billid:that.billid}, "*");	
								that.data_xs.xiaohua_id="dce";								
								var data_sess = JSON.stringify(that.data_xs);								
								sessionStorage.setItem("data_xs", data_sess);	
							})
						} else if(msg.code == 201 || msg.code == 202) {
							that.tips_modal = msg.msg;
							$('#myModal_tips').modal('show');
							that.sure_pay = "确定"
						}
					},
					error: function() {
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
					}
				});
			},
			//支付宝小包查询接口
			wx_zfb_search1: function() {
				$('.sure_pay').prop('disabled', true);
				var that = this;
				var data_1 = {
					id: that.id_type.billid,
					billtype: that.id_type.billtype,
					areaid: that.areaid,
				}
				$.ajax({
					url: that.url_bao + '/action/tradequery',
					type: "POST",
					async: true,
					data: JSON.stringify(data_1),
					dataType: "json",
					contentType: "application/json",
					success: function(msg) {
						$('.sure_pay').prop('disabled', false);
						//						console.log(msg);
						if(msg.code == 200) {
							$('#myModal_tips').on('hide.bs.modal', function() {
//								window.location.href("index.html?repaint=paid_the_bill&order=" + that.billid);
								window.parent.postMessage({billid:that.billid}, "*");
								that.data_xs.xiaohua_id="dce";								
								var data_sess = JSON.stringify(that.data_xs);								
								sessionStorage.setItem("data_xs", data_sess);	
							})
							that.tips_modal = msg.msg;
							$('#myModal_tips').modal('show');
							$('#myModal_tips2').modal('hide');
						} else if(msg.code == 201 || msg.code == 202) {
							that.tips_modal = msg.msg;
							$('#myModal_tips').modal('show');
							that.sure_pay = "确定"
						}
					},
					error: function() {
						that.tips_modal = "获取信息失败";
						$('#myModal_tips').modal('show');
					}
				});
			},
		}

	})
</script>